import Vue from "vue";
import Router from "vue-router";
import route from "./routes";
import warningManagement from "./warningManagement"; // 预警管理
import EmergencyDisposal from "./EmergencyDisposal"; // 应急处置
import EmergencyPlan from "./EmergencyPlan"; // 应急预案
import TrainingAndExercise from "./TrainingAndExercise"; // 培训演练
import Duty from "./Duty"; // 值班
import OperationMonitor from "./OperationMonitor"; // 值班
import EmergencyResources from "./EmergencyResources"; // 值班
import SystemHomepage from "./SystemHomepage"; // 系统首页
import SystemConfig from "./SystemConfig"; // 系统配置
import OperationalMonitoring from "./OperationalMonitoring"; // 运行监测
import emergencyRepair from "./emergencyRepair";


// hack router push callback
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch((err) => err);
};

Vue.use(Router);
const routes = [
  ...route,
  ...warningManagement, // 预警管理
  ...EmergencyDisposal, // 应急处置
  ...EmergencyPlan, // 应急预案
  ...TrainingAndExercise, // 培训演练
  ...Duty, // 值班
  ...OperationMonitor,
  ...EmergencyResources,
  ...SystemHomepage,
  ...SystemConfig,
  ...OperationalMonitoring,
  ...emergencyRepair// 应急抢修
];
export default new Router({
  mode: "history",
  base: process.env.VUE_APP_BASE_API,
  routes: routes
});
